//
//  StealthModeVC.m
//  SelfDriving
//
//  Created by apple on 16/1/11.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "StealthModeVC.h"
#import "BlackCell.h"
#import "BusinessService+User.h"
#import "SVProgressHUD.h"
#import "AppDelegate.h"
@interface StealthModeVC ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *table;

@end

@implementation StealthModeVC
{
    int btnindex;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.navigationBarHidden = NO;
}
-(void)viewWillAppear:(BOOL)animated{
     [[AppDelegate shareDelegate]refdata:^(id res) {
        btnindex = [[AppDelegate shareDelegate].user.yinsi_type intValue];
        [_table reloadData];
     }];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    BlackCell *cell = [tableView dequeueReusableCellWithIdentifier:@"StealthCell1"];
    
    if (indexPath.row == 0) {
        cell.imageView.image = [UIImage imageNamed:@"sykj"];
        cell.labelname.text = @"对所有人可见";
        cell.content.text = @"对所有人显示距离";
    }
    if (indexPath.row == 1) {
        cell.imageView.image = [UIImage imageNamed:@"hykj"];
        cell.labelname.text = @"对好友可见";
        cell.content.text = @"对好友显示距离，不出现在附近";
    }
    if (indexPath.row == 2) {
        cell.imageView.image = [UIImage imageNamed:@"nokj"];
        cell.labelname.text = @"对所有人隐身";
        cell.content.text = @"对所有人隐身，不出现在附近";
    }
    if (btnindex == indexPath.row) {
        cell.btnClater.selected = YES;
    }else{
        cell.btnClater.selected = NO;
    }
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    btnindex = (int)indexPath.row;
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setObject:[NSNumber numberWithInt:btnindex] forKey:@"type"];
    [[BusinessService shareInstance]setYinsi_type:dic success:^(id result) {
        [SVProgressHUD showSuccessWithStatus:@"设置成功"];
        [tableView reloadData];
    } failure:^(id result) {
        [SVProgressHUD showErrorWithStatus:result];
    }];
}

- (IBAction)backActino:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}






- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
